package com.wisdytech.linkdcs.equipLifeCycle.maintain.action;


import com.github.pagehelper.PageInfo;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.StandardResult;
import com.wisdytech.common.bean.StandardTableResult;
import com.wisdytech.common.handler.ResourceMatchingService;
import com.wisdytech.common.utils.BaseUtil;
import com.wisdytech.linkdcs.equipLifeCycle.maintain.model.RepairManage;
import com.wisdytech.linkdcs.equipLifeCycle.maintain.service.IRepairManageService;
import com.wisdytech.linkdcs.system.model.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhanghailin
 * @since 2018-07-19
 */
@Controller
@RequestMapping("/equipment/repairManage")
public class RepairManageAction {

    @Resource
    private IRepairManageService repairManageService;
    @Autowired
    @Qualifier("resourceMatchingService")
    private ResourceMatchingService resourceMatchingService;
    /**
     * 设备检修管理
     * @param model model
     * @return page
     */
    @RequestMapping("/index")
    public String index(Model model, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        return "lifeCycle/equipLifeCycle/maintain/repairManage";
    }

    @RequestMapping("/findRepairManageByPage/get.mvc")
    @ResponseBody
    public StandardTableResult<RepairManage> findRepairManageByPage(String equipCode, String equipName, String maintenanceProject, String dutyDepartment, String maintenanceStartDate, String maintenanceEndDate, Filter filter) {
        PageInfo<RepairManage> page = this.repairManageService.findRepairManageByPage(equipCode,equipName,maintenanceProject,dutyDepartment,maintenanceStartDate,maintenanceEndDate,filter);
        return new StandardTableResult<>(page.getTotal(),page.getList());
    }

    @RequestMapping("/saveOrUpdateRepairManage/save.mvc")
    @ResponseBody
    public StandardResult saveOrUpdateRepairManage(RepairManage repairManage) {
        SysUser operator = BaseUtil.getCurrentUser();
        this.repairManageService.saveOrUpdateRepairManage(repairManage,operator);
        return StandardResult.getSuccessResult();
    }

    @RequestMapping("/findRepairManageById/get.mvc")
    @ResponseBody
    public StandardResult findRepairManageById(String pkId) {
        RepairManage repairManage = this.repairManageService.findRepairManageById(pkId);
        return StandardResult.getSuccessResult(repairManage);
    }

    @RequestMapping("/logicDeleteRepairManageByPkIds/del.mvc")
    @ResponseBody
    public StandardResult logicDeleteRepairManageByPkIds(String pkIds) {
        this.repairManageService.logicDeleteRepairManageByPkIds(pkIds);
        return StandardResult.getSuccessResult();
    }

}

